#include <fstream>
#include <set>
#include <vector>
#include <utility>
using namespace std;
const double INF = 1000000000;
int n;

void dijkstra(const vector<vector<pair<int,double> > > graph, int start, vector<int>& d, vector<int>& p) {
    d.resize(n, INF);
    p.resize(n,-1);
    d[start] = 0;

    set< pair<double,int> > q;
    q.insert(make_pair(d[start],start));

    while (!q.empty()) {
        int v = q.begin()->second;
        q.erase(q.begin());

        for (int i=0; i<graph[v].size(); i++){
            int to = graph[v][i].first;
            double len = graph[v][i].second;
            if (d[v] + len < d[to]) {
                q.erase(make_pair(d[to],to));
                d[to] = d[v] + len;
                p[to] = v;
                q.insert(make_pair(d[to],to));
            }
        }
    }
}


int main() {
    ifstream in("in.txt");
    ofstream out("out.txt");

    in >> n;

    vector <vector <pair<int,double> > > graph(n);
    int start, finish;
    in >> start >> finish;

    while(!in.eof()) {
        int a,b;
        double w;
        in >> a >> b >> w;
        graph[a].push_back(make_pair(b,w));
    }

    vector<int> d;
    vector<int> p;

    dijkstra(graph,start,d,p);

    if (p[finish] == -1) {
        out << "No\n";
        return 0;
    }

    int current = finish;
    double min = INF + 1;
    //vector<int> second_p;
    while (p[current] != -1) {
        vector<pair<int,double> >::iterator it = graph[p[current]].begin();
        for (; it->first != p[current]; it++);
        pair<int,double> edge = *it;
        graph[p[current]].erase(it);

        vector<int> newd(n,INF);
        vector<int> newp(n,-1);

        dijkstra(graph,start,newd,newp);

        if (newp[finish] != -1 && newd[finish] < min)
            min = newd[finish];

        graph[p[current]].push_back(edge);
        current = p[current];

    }

    if (min >= INF) {
        out << "No\n";
    } else out << "Yes\n" << min;

    return 0;

}
